package com.kx.center.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class ContextListener implements ServletContextListener {

	public void contextDestroyed(ServletContextEvent arg0) {
		
	}

	public void contextInitialized(ServletContextEvent arg0) {

		ServletContext scontext = arg0.getServletContext();
		
		Context.getInstance().setContext(scontext);
		scontext = Context.getInstance().getContext();
		ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(scontext);
		Context.getInstance().setApplicationContext(ctx);
	}

}
